package com.example.springworkadmin.dao;

import com.example.springworkadmin.entity.CheckerAccount;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository

public interface CheckerAccountDao {

    @Select("select count(*) from inspectors where name like concat('%',#{key},'%')")
    Integer count(@Param("key") String key);

    @Select("select * from inspectors where name like concat('%',#{key},'%') order by account desc limit #{start},#{size}")
    List<CheckerAccount> get(@Param("start")Integer start,@Param("size")Integer limit,@Param("key")String key);

    @Insert("insert into inspectors(account,password,name,phone) values(#{o.account},#{o.password},#{o.name},#{o.phone})")
    Integer add(@Param("o")CheckerAccount checkerAccount);

    @Update("update inspectors set password=#{o.password},name=#{o.name},phone=#{o.phone} where account=#{o.account}")
    Integer update(@Param("o")CheckerAccount checkerAccount);

    @Delete("delete from inspectors where account=#{id}")
    Integer delete(@Param("id")String id);
}
